#pragma once
#include <stdint.h>
#include <vector>
#include <string>
#include <sys/time.h>

typedef struct
{
    unsigned long long read_sectors;
    unsigned long long write_sectors;
    struct timespec ts;
    // 计算值
    float read_speed;
    float write_speed;
} diskIo_t;

typedef struct
{
    std::string dev_name;
    uint64_t read_count;
    diskIo_t disk_io;
} sysDiskIo_t;

class MonitorDiskIo
{
public:
    MonitorDiskIo(std::string& dev_name);
    ~MonitorDiskIo();
    sysDiskIo_t* update_diskIo(bool opt_cal_ioSpeed = true);
    diskIo_t read_diskState(const std::string devname);
    void cal_diskIoSpeed(sysDiskIo_t* prev, sysDiskIo_t* curr);
    void show_diskIoSpeed(sysDiskIo_t* diskIo);
private:
    sysDiskIo_t sysDiskIo_[2];
    std::string Disk_Name_;
    const std::string DiskStats_File = "/proc/diskstats";
};